<?php
/**
 * Created by PhpStorm.
 * User: prg
 * Date: 2017/3/27
 * Time: 19:41
 */

//管理员后台查看团队详情接口

require_once 'db.php';
require_once 'response.php';

header('content-type:text/html;charset:utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET');
header('Access-Control-Allow-Headers:x-requested-with,content-type');

$id = isset($_GET['teamId']) ? $_GET['teamId'] : '';

if(!is_numeric($id)) {
    return Response::show(401,'数据不合法');
}

try {
    $connect = Db::getInstance()->connect();
} catch (Exception $e) {
    return Response::show(403,'数据库连接失败',$e->getMessage());
}

$sql = "SELECT * FROM team WHERE team_id={$id}";

$res = $connect->query($sql);
$data = array();

if($res && $res->num_rows>0) {
    while($info = $res->fetch_assoc()) {
        $data[] = $info;
    }
    return Response::show(200,'团队详情获取成功',$data);
    var_dump($data);
} else {
    return Response::show(404, '团队详情获取失败',$data);
}